﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using SharpMap.Layers;
using System.Windows;
using SharpMap.Styles;
namespace SharpMap.Wpf
{
    public class MapLayerViewModel : INotifyPropertyChanged
    {
        FrameworkElement _view;
        ILayer _layer;

        public ILayer Layer
        {
            get { return _layer; }
        }
        public MapLayerViewModel(ILayer layer, FrameworkElement view)
        {
            _layer = layer;
            _view = view;
            _layer.PropertyChanged +=new PropertyChangedEventHandler(layerPropertyChanged);
        }

        void  layerPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
 	        if(e.PropertyName == "Style")
            {
                RaisePropertyChanged("Style");
            }
        }

        public IStyle Style
        {
            get { return _layer.Style; }
            set {  _layer.Style = value; }
        }
        
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                PropertyChangedEventArgs args =
                    new PropertyChangedEventArgs(propertyName);
                handler(this, args);
            }
        }
        #endregion

    }
}
